package com.ioftv.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ioftv.entity.Labeler;
import com.ioftv.mapper.LabelerMapper;
import com.ioftv.service.LabelerService;
import com.ioftv.service.base.BaseService;
import org.springframework.stereotype.Service;

/**
 * 标注员Service实现类
 */
@Service
public class LabelerServiceImpl extends BaseService<LabelerMapper, Labeler> implements LabelerService {

    @Override
    public Labeler getByEmployeeId(String employeeId) {
        LambdaQueryWrapper<Labeler> queryWrapper = createUserQueryWrapper();
        queryWrapper.eq(Labeler::getEmployeeId, employeeId);
        return this.getOne(queryWrapper);
    }

    @Override
    protected void addUserCondition(LambdaQueryWrapper<Labeler> queryWrapper) {
        queryWrapper.eq(Labeler::getUserId, getCurrentUserId());
    }

    @Override
    protected void setEntityUserId(Labeler entity) {
        if (entity.getUserId() == null) {
            entity.setUserId(getCurrentUserId());
        }
    }
}